#!/bin/bash

source Common

# script to help with building a source release package
#
# parameter 1 is the output directory
# parameter 2 is the version being released
#

function PrintUsage()
{
  echo "usage:";
  echo "  ./make_src_release OutputDirectory VersionNumber TagName";
  echo "";
  echo "example:";
  echo "  ./make_src_release ~/packetdotnet_releases 2.0.0";
}

if [ "$#" -ne 2 ]; then
  PrintUsage
  exit
fi

echo "make_src_release $1 $2"

baseOutputDirectory=$1
releaseVersion=$2
githubSvnPath=https://github.com/chmorgan/packetnet/tags/

# setup some variables
baseOutputDirectory=${baseOutputDirectory}/src
mkdir -p ${baseOutputDirectory}
outputName=PacketDotNet-${releaseVersion}

# build the tag by converting the '.' in the version to '_'
tag=PacketDotNet_${2//./_}

# export the files to a temporary folder
svn export ${githubSvnPath}/$tag ${baseOutputDirectory}/$tag

# create a zip file
zip -r ${baseOutputDirectory}/${outputName}.src.zip ${baseOutputDirectory}/$tag
